✨ BCA JUL24 Batch ✨

Join Our WhatsApp Group

Anukasif Pic

2.3 - Operators - MCQs

Interactive MCQs Quiz

Test your knowledge with these questions

2. Which of the following is a unary operator?

3. In a pre-increment operation, which of the following is correct?

4. What will be the output of the following code?

int x = 10, y = 20;
            int p = ++x + ++y;
            printf("%d\n", p);

5. In a pre-decrement operation, what happens to the variable?

6. What will be the output of the following code?

int x = 10, y = 20;
            int p = --x - --y;
            printf("%d\n", p);

7. In a post-increment operation, which of the following is correct?

8. What will be the output of the following code?

int x = 10, y = 20;
            int p = x++ + y++;
            printf("%d\n", p);

9. In a postfix decrement operation, when is the variable decremented?

10. What will be the output of the following code?

int x = 10, y = 20;
            int p = x-- - y--;
            printf("%d\n", p);

11. Which of the following operators is used for binary operations?

12. What will be the output of the following code?

int a = 10, b = 100;
            float c = 10.5, d = 100.5;
            printf("++a = %d \n", ++a);
            printf("--b = %d \n", --b);
            printf("++c = %f \n", ++c);
            printf("--d = %f \n", --d);

13. Which operator is used for addition in C programming?

14. What will be the result of the operation 9 % 4 in C programming?

15. Which operator is used for multiplication in C programming?

16. What is the result of a / b when a = 9 and b = 4 if both are integers?

17. Which operator is used to find the remainder after division?

18. Which operator checks if two values are equal?

19. Which operator checks if two values are not equal?

20. Which relational operator checks if the left operand is greater than the right operand?

21. Which operator checks if the left operand is less than the right operand?

22. What does the >= operator check?

23. What does the <= operator check?

24. What is the output of the following code:
printf("%d == %d is %d \n", a, b, a == b); if a = 5 and b = 5?

25. Which logical operator represents AND operation in C?

26. Which logical operator represents OR operation in C?

27. Which logical operator represents NOT operation in C?

28. What is the result of the expression (a == b) && (c > b) if a = 5, b = 5, and c = 10?

29. What does the expression !(a == b) return when a = 5 and b = 5?

30. What is the output of (a != b) || (c < b) if a = 5, b = 5, and c = 10?

31. Which assignment operator adds the right operand to the left operand and assigns the result to the left operand?

32. Which assignment operator is used to subtract and assign the result?

33. Which assignment operator multiplies the left operand with the right operand and assigns the result to the left operand?

34. What is the output of the following code:
int a = 5, c;
c = a;
c += a;
printf("%d", c);

35. Which assignment operator divides the left operand by the right operand and assigns the result to the left operand?

36. Which assignment operator is used to take modulus and assign the result?

37. What is the output of the following code:

 
                    int a = 5, c;
                    c = a;
                    c %= a;
                    printf("%d", c);
                

38. Which operator in C is used to perform a bitwise AND operation on two numbers?

39. What is the output of the following C code:

#include <stdio.h>
            
            int main() {
                int a = 12, b = 25;
                printf("Output = %d", a & b);
                return 0;
            }
                

40. What does the bitwise OR operator ( | ) do in C?

41. What is the output of the following C code:

#include <stdio.h>
            
            int main() {
                int a = 12, b = 25;
                printf("Output = %d", a | b);
                return 0;
            }
                

42. Which operator performs a bitwise XOR operation in C?

43. What is the result of a bitwise XOR operation between 12 and 25 in C?

#include <stdio.h>
            
            int main() {
                int a = 12, b = 25;
                printf("Output = %d", a ^ b);
                return 0;
            }
                

44. Which operator in C shifts the bits of a number to the left?

45. Which operator in C shifts the bits of a number to the right?

46. What is the output of the following code snippet for right shift operation in C?

#include <stdio.h>
            int main() {
                int num = 212, i;
                for (i = 0; i <= 2; ++i) {
                    printf("Right shift by %d: %d\n", i, num >> i);
                }
                return 0;
            }
                

47. What is the output of the following code snippet for left shift operation in C?

#include <stdio.h>
            int main() {
                int num = 212, i;
                for (i = 0; i <= 2; ++i) {
                    printf("Left shift by %d: %d\n", i, num << i);
                }
                return 0;
            }
                

48. Which operator in C inverts all bits of a number?

49. What is the output of the following code using the bitwise NOT operator?

#include <stdio.h>
            int main() {
                printf("Output = %d\n", ~35);
                printf("Output = %d\n", ~-12);
                return 0;
            }
                

50. What is the ternary operator (also called the conditional operator) used for in C?

51. What is the output of the following C code using the conditional (ternary) operator?

#include <stdio.h>
            int main() {
                int age;
                printf("Enter your age: ");
                scanf("%d", &age);
                (age >= 18) ? printf("You can vote") :
                 printf("You cannot vote");
                return 0;
            }
                

52. Which operator returns the size of a variable in C?

53. What is the output of the following C code using the sizeof operator?

#include <stdio.h>
            int main() {
                int a = 5;
                printf("Size of a = %lu\n", sizeof(a));
                return 0;
            }
                

54. What does the & operator do in C when applied to a variable?

55. Which operator in C is used as a pointer dereference operator to access the value at a given address?

56. What is the output of the following C code using pointer dereferencing?

#include <stdio.h>
            void main() {
                int i = 5;
                int *ptr;
                ptr = &i;
                printf("Value of *ptr is %d.\n", *ptr);
            }
                

57. Which of the following operators has the highest precedence?

58. How will the expression 2 + 3 * 4 be evaluated based on operator precedence?

59. Which operator has the lowest precedence among the following?

60. What is the result of the expression (2 + 3) * 4 when parentheses are used to change precedence?

61. What is the associativity of the assignment operator (=) in the expression x = y = z?

62. In the expression 2 + 3 + 4, which operation will be performed first due to left-to-right associativity?

63. Which of the following statements is true regarding operator precedence?

64. Which operator is left-associative?

65. In the expression a = b + c * d, which operation is performed first?

66. What is the associativity of the logical OR (||) operator?